window.addEventListener('load', function () {

    const sectionSpan = this.document.querySelectorAll('.section span')
    const select = this.document.querySelectorAll('.section .select')
    const inputs = this.document.querySelectorAll('input')
    const textarea = this.document.querySelector('textarea')
    const button = this.document.querySelector('button')


    for (let i = 0; i < sectionSpan.length; i++) {
        sectionSpan[i].addEventListener('click', function (e) {
            for (let j = 0; j < sectionSpan.length; j++) {
                sectionSpan[j].style.backgroundColor = 'rgb(94,94,94)'
                sectionSpan[j].style.color = 'rgb(255,255,255)'
            }
            e.target.style.backgroundColor = '#fff'
            e.target.style.color = '#000'

            for (let i = 0; i < select.length; i++) {
                select[i].style.display = 'none'
            }
            if (e.target.dataset.index == sectionSpan.length - 1) {
                select[e.target.dataset.index].style.display = 'flex'
            } else {
                select[e.target.dataset.index].style.display = 'block'
            }
        })
    }


    let arr = []
    for (i = 0; i < inputs.length; i++) {
        inputs[i].addEventListener('focus', function (e) {
            e.target.placeholder = ''
        })
    }
    for (i = 0; i < inputs.length; i++) {
        let content = inputs[i].placeholder
        inputs[i].addEventListener('blur', function (e) {
            e.target.placeholder = content
        })
    }




    let content = textarea.placeholder
    textarea.addEventListener('focus', function () {
        textarea.placeholder = ''
    })
    textarea.addEventListener('blur', function () {
        textarea.placeholder = content
    })



    button.addEventListener('click', function () {
        for (let i = 0; i < inputs.length; i++) {
            let content = inputs[i].value
            arr.push(content)
        }
        console.log(arr);
    })
})
// const iframe = document.querySelector('iframe')
// window.addEventListener('beforeunload', function (e) {
//     e.preventDefault()
// })